import request from '@/utils/http'

<% for (const api of apis) { -%>
<% const apiName = formatter.apiName(api.url, api.method, api.path) %>
<% if (api.apiInfo) { -%>
/** <%- api.apiInfo %> */
<% } -%>
export const <%- apiName %> = (
<% if (api.path?.length) { -%>
<%- utils.getReqPath(api.path) %>
<% } -%>
<% if (api.data) { -%>
<% const reqtype = utils.getReqType(schemasList, 'data', api.data, 1) -%>
data:<%- reqtype %>,
<% } else if (api.formData) { -%>
<% const reqtype = utils.getFormDataParameters(api.formData) -%>
data:<%- reqtype %>,
<% } -%>
<% if (api.query?.length) { -%>
<% const reqtype = utils.getReqQuery(schemasList, api.query) -%>
query:<%- reqtype %>,
<% } -%>
  config?: RequestConfig
) =>
request.<%- api.method %><ResponseList<<%- api.response %>>>({
  apiInfo: <%- JSON.stringify(api.apiInfo) %>,
  url: <%- utils.getReqUrl(api.url, api.path) %>,
<% if (api.data) { -%>
  data,
<% } else if (api.formData) { -%>
  contentType: 'multipart/form-data',
  data,
<% } -%>
<% if (api.query?.length) { -%>
  query,
<% } -%>
  ...config
})

<% } -%>
